import Vue from 'vue'
import moment from "moment"
// formatTime
Vue.filter('dateFormat', function (dateStr, pattern = "") {
  //根据给定的时间字符串，得到特定的时间
  var dt = new Date(dateStr)
  //yyy---mm-dd
  var y = dt.getFullYear() //得到年份
  var m = dt.getMonth() + 1 //得到月份
  var d = dt.getDate() //得到日期
  // return y + '-' + m + '-' + d
  if (pattern.toLowerCase() === "yyyy-mm-dd") {
    return `${y}-${m}-${d}`
  } else {
    var hh = dt.getHours() //得到时
    var mm = dt.getMinutes() //得到分
    var ss = dt.getSeconds() //得到秒
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
})
Vue.filter("gettime",function(value){//时间戳转化
  return   moment.unix(value).format("YYYY-MM-DD HH:mm:ss");
})
Vue.filter("choseTime",function(value){//GMT时间转换
  return   moment(value).format("YYYY-MM");
})
Vue.filter("getmoney",function(value){//金额转换分转成元
  if(value==undefined){
    return 0
  }else{
    return  String(value/100).replace(/^(.*\..{2}).*$/ ,"$1")  
  }
    
})
Vue.filter("getmoneys",function(value){//金额转换分转成元不要后面的00
  if(value==undefined){
    return 0
  }else{
    return   String(value/100).replace(/^(.*\..{2}).*$/ ,"$1")
  }
    
})
Vue.filter("getmoney1",function(value){//金额转换分转成厘
  if(value==undefined){
    return 0
  }else{
    return   String(value/100).replace(/^(.*\..{4}).*$/,"$1")
  }
})
Vue.filter("time",function(value){//时间修改格式
  if(value < 10){
    return '0' + value 
  }else{
    return value
  }
})
Vue.filter("photo",function(value){//头像
  switch (value) {
    case 1:
      return  require('../assets/avatar/1.png') 
    case 2:
      return require('../assets/avatar/2.png') 
    case 3:
      return require('../assets/avatar/3.png') 
    case 4:
      return require('../assets/avatar/4.png') 
    case 5:
      return require('../assets/avatar/5.png') 
    case 6:
      return require('../assets/avatar/6.png') 
    case 7:
      return require('../assets/avatar/7.png') 
    case 8:
      return require('../assets/avatar/8.png') 
    case 9:
      return require('../assets/avatar/9.png') 
    case 10:
      return require('../assets/avatar/10.png') 
    case 11:
      return require('../assets/avatar/11.png') 
    case 12:
      return require('../assets/avatar/12.png') 
    default:
      return require('../assets/avatar/1.png') 
  }
})
Vue.filter("yuebaolixi",function(value){//余额宝利息率
  
  return  String(value/100/365*1000).replace(/^(.*\..{2}).*$/ ,"$1") 
})
Vue.filter("yuebaolixi1",function(value){//余额宝利息率1
  return   String(value/100/365*10000).replace(/^(.*\..{2}).*$/ ,"$1") 
})
Vue.filter("yuebaolixi2",function(value){//余额宝利息率2
  return  String(value/100/365*100000).replace(/^(.*\..{2}).*$/ ,"$1")  
})
Vue.filter("zhengfu",function(value){
  if(value.indexOf('-')=="-1"){
      return 'Transfer in'
  }else{
     return 'Transfer out'
  }
})
